<?php
class Application_Model_Dia extends Zend_Db_Table_Abstract
{
	// Table Name
	protected $_name = 'dia';
	// Primary Key
	protected $_primary = 'id_dia';
	
	// Insert
	public function insert(array $data)
	{
		return	parent::insert($data);
	}
	
	// Update
	public function update(array $data, $where)
	{
		return parent::update($data, $where);
	}
	
	// Delete
	public function delete($where)
	{
		return parent::delete($where);
	}
	
	public function selectAll($future = false)
	{
		$select = $this->select();
		$select->from(array('d' => 'dia'),array(new Zend_Db_Expr("to_char(d.dia, 'dd-mm-YYYY') as dia"),'d.id_dia'));
		if($future == true)
		{
			$select->where('dia >= ?',date('Y-m-d'));
		}
		return $this->fetchAll($select);
	}
	
	public function selectDay($dia = null)
	{
		$select = $this->select();
		
		$select->where('dia = ?',$dia);
		
		return $this->fetchRow($select);
	}
}